package com.lz.autotest.common.web.domain;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.lz.autotest.project.testmanage.autoTest.entity.TsstAutotestMenu;
import com.lz.autotest.project.system.domain.SysDept;
import com.lz.autotest.project.system.domain.SysMenu;
import com.lz.autotest.project.testmanage.infmanage.domain.SstInf;

/**
 * Treeselect树结构实体类
 *
 * @author lz
 */
public class TreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private String id;

    /** 节点名称 */
    private String label;

    /** 路由地址 */
    private String path;

    private String type;

    /** 组件路径 */
    private String component;


    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getComponent() {
        return component;
    }

    public void setComponent(String component) {
        this.component = component;
    }

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(SysDept dept)
    {
        this.id = dept.getDeptId();
        this.label = dept.getDeptName();
        this.type = dept.getLeader();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
    public TreeSelect(SstInf dept)
    {
        this.id = dept.getInfId();
        this.label = dept.getInfId();
        this.type = dept.getInfUrl();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TsstAutotestMenu item)
    {
        this.id =  item.getMenuId() + "";
        this.label = item.getMenuName();
        this.type = item.getMenuType();
        this.children = item.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SysMenu menu)
    {
        this.id = menu.getMenuId().toString();
        this.path =  menu.getPath();
        this.component = menu.getComponent();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }


    public List<TreeSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelect> children)
    {
        this.children = children;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
